﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model.Po;
using nERP.Model.Bas;
using nERP.Model.Wms;

namespace nERP.Model.Wms
{
    /// <summary>
    /// 采购退货出库
    /// </summary>
	[Table("BuyReturnOutWarehouse")]
    [SoftKey(nameof(BuyReturnOutWarehouse.BuyReturnOutWarehouseCode))]
    [Display(Name = "_Model.BuyReturnOutWarehouse")]
    public class BuyReturnOutWarehouse : BasePoco,IPersistPoco,ITenant,IWorkflow
    {
        [Display(Name = "_Model._BuyReturnOutWarehouse._BuyReturnOutWarehouseCode")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("采购退货出库单号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string BuyReturnOutWarehouseCode { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._BuyReturn")]
        [Comment("采购退货")]
        [NotMapped]
        public BuyReturn BuyReturn { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._BuyReturn")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("采购退货")]
        public string BuyReturnId { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._Buy")]
        [Comment("采购订单")]
        [NotMapped]
        public Buy Buy { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._Buy")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("采购订单")]
        public string BuyId { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._Supplier")]
        [Comment("供应商")]
        [NotMapped]
        public Supplier Supplier { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._Supplier")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("供应商")]
        public string SupplierId { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._MakeUser")]
        [Comment("制单人")]
        [NotMapped]
        public FrameworkUser MakeUser { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._MakeUser")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("制单人")]
        public string MakeUserId { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._InvoicesDate")]
        [Comment("单据日期")]
        public DateTime? InvoicesDate { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._InvoicesImage")]
        [Comment("单据附件")]
        public List<BuyReturnOutWarehouseInvoicesImage> InvoicesImage { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._Status")]
        [Comment("单据状态")]
        public StatusTypeEnum? Status { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._Remark")]
        [StringLength(256, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouseDetail._BuyReturnOutWarehouse")]
        [InverseProperty("BuyReturnOutWarehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.BuyReturnOutWarehouseDetail.BuyReturnOutWarehouseId))]
        public List<BuyReturnOutWarehouseDetail> BuyReturnOutWarehouseDetail_BuyReturnOutWarehouse { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouse._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}
    public class BuyReturnOutWarehouseInvoicesImage : TopBasePoco, ISubFile
    {
        public Guid BuyReturnOutWarehouseId { get; set; }
        public BuyReturnOutWarehouse BuyReturnOutWarehouse { get; set; }
        public Guid FileId { get; set; }
        public FileAttachment File { get; set; }
        public int Order { get; set; }
    }

}
